﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using DevComponents.DotNetBar;

namespace ChangWuDiBang
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            //Application.Run(new FrmBase64Encoding());

            FrmLogin frmlogin = new FrmLogin();
            FrmMain frmmain = new FrmMain();
            if (frmlogin.ShowDialog() == DialogResult.OK)
            {
                frmlogin.Close();
                frmmain._UserInfo = frmlogin._UserInfo;
                Application.Run(frmmain);
            }
        }

        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            MessageBoxEx.Show(e.Exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
            // here you can log the exception ...
        }
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageBoxEx.Show((e.ExceptionObject as Exception).Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
            // here you can log the exception ...
        }
    }
}
